-
Notifications
You must be signed in to change notification settings - Fork 782
Feat/cloud observability example #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds a new observability example for MCP (Python app, OpenTelemetry, Langfuse) with configs and docs; updates MCP example README with Inspector settings; changes logger transport from file to console in an existing MCP example; removes an inline comment in a temporal requirements file. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant GradeStory as grade_story_async()
participant Magic as get_magic_number()
participant Parallel as ParallelLLM
participant Agents as Agents (Proofreader,FactChecker,StyleEnforcer,Grader)
participant OTEL as OpenTelemetry
Client->>GradeStory: invoke grade_story_async(story)
GradeStory->>OTEL: start trace/span
GradeStory->>Magic: compute magic number (sync)
Magic-->>GradeStory: magic_number (span recorded)
GradeStory->>Parallel: execute ParallelLLM (fan-out)
Parallel->>Agents: run Proofreader,FactChecker,StyleEnforcer (parallel)
Agents-->>Parallel: results
Parallel->>Agents: run Grader (fan-in)
Agents-->>Parallel: final grade
Parallel-->>GradeStory: aggregated result
GradeStory->>OTEL: log result & end span
GradeStory-->>Client: return final grade
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
||
|
|
||
| # You can always explicitly trace using opentelemetry as usual | ||
| def get_magic_number(original_number: int = 0) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thing that may be great to add would be a function decorated as an app.workflow_task, which is then called via app_ctx.executor.execute. That will execute the function as an activity, and will be great to show that. Totally optional, but wanted to suggest that for completeness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/cloud/observability/main.py (1)
52-79: Consider passing context to Agent instances for better tracing.The Agent instances are created without an explicit
contextparameter. While the Agent class falls back toget_current_context()internally, explicitly passing the context ensures proper tracing context propagation and access to app configuration.Apply this pattern to improve context propagation:
proofreader = Agent( name="proofreader", instruction="""Review the short story for grammar, spelling, and punctuation errors. Identify any awkward phrasing or structural issues that could improve clarity. Provide detailed feedback on corrections.""", + context=context, ) fact_checker = Agent( name="fact_checker", instruction="""Verify the factual consistency within the story. Identify any contradictions, logical inconsistencies, or inaccuracies in the plot, character actions, or setting. Highlight potential issues with reasoning or coherence.""", + context=context, ) style_enforcer = Agent( name="style_enforcer", instruction="""Analyze the story for adherence to style guidelines. Evaluate the narrative flow, clarity of expression, and tone. Suggest improvements to enhance storytelling, readability, and engagement.""", + context=context, ) grader = Agent( name="grader", instruction="""Compile the feedback from the Proofreader and Fact Checker into a structured report. Summarize key issues and categorize them by type. Provide actionable recommendations for improving the story, and give an overall grade based on the feedback.""", + context=context, )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
examples/cloud/mcp/README.md(1 hunks)examples/cloud/mcp/mcp_agent.config.yaml(1 hunks)examples/cloud/observability/README.md(1 hunks)examples/cloud/observability/main.py(1 hunks)examples/cloud/observability/mcp_agent.config.yaml(1 hunks)examples/cloud/observability/mcp_agent.secrets.yaml.example(1 hunks)examples/cloud/observability/requirements.txt(1 hunks)examples/temporal/requirements.txt(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
examples/cloud/observability/main.py (5)
src/mcp_agent/agents/agent.py (1)
Agent(62-1161)src/mcp_agent/server/app_server.py (2)
app(244-246)create_mcp_server_for_app(504-2042)src/mcp_agent/core/context.py (2)
Context(65-323)name(195-198)src/mcp_agent/workflows/llm/augmented_llm_openai.py (1)
OpenAIAugmentedLLM(83-926)src/mcp_agent/workflows/parallel/parallel_llm.py (1)
ParallelLLM(25-282)
🪛 LanguageTool
examples/cloud/observability/README.md
[style] ~3-~3: Try moving the adverb to make the sentence clearer.
Context: ... OTLP exporter (Langfuse). It shows how to automatically trace tool calls, workflows, LLM calls, and add custom t...
(SPLIT_INFINITIVE)
🔇 Additional comments (7)
examples/temporal/requirements.txt (1)
1-7: Verify cloud deployment guidance is documented elsewhere.The inline comment instructing developers to remove the local
mcp-agentpath for cloud deployment has been removed. While this file may be intended for local development, the PR description states this is a "cloud-deployable example." Without the reminder, developers using this as a template may not realize they need to changefile://../../to a published package version (e.g.,mcp-agent==X.Y.Z) before deploying to the cloud.Confirm that cloud deployment steps are clearly documented in a deployment guide or README, or consider restoring the comment to prevent accidental misconfiguration.
examples/cloud/mcp/mcp_agent.config.yaml (1)
1-6: LGTM! Console logging is appropriate for cloud deployment.The change from file-based to console-based logging aligns well with cloud deployment practices where logs are typically captured from stdout/stderr by the container orchestration platform.
examples/cloud/observability/mcp_agent.secrets.yaml.example (1)
1-14: LGTM! Well-structured secrets example with helpful documentation.The example file provides clear placeholders and includes helpful inline comments referencing the Langfuse documentation and the command for generating the basic auth token.
examples/cloud/mcp/README.md (1)
187-198: LGTM! Helpful Inspector configuration guidance.The added documentation clearly outlines the required Inspector settings and includes a practical tip about adjusting request timeouts for LLM operations.
examples/cloud/observability/mcp_agent.config.yaml (1)
1-11: LGTM! Clean observability configuration.The configuration properly enables OpenTelemetry with a descriptive service name and appropriately references the OTLP exporter configuration in the secrets file, maintaining good separation of concerns.
examples/cloud/observability/README.md (1)
1-159: LGTM! Comprehensive and well-structured documentation.This README provides excellent guidance covering all necessary aspects: features, prerequisites, configuration, local testing, deployment, and debugging. The step-by-step instructions and examples make it easy for users to get started with the observability features.
examples/cloud/observability/main.py (1)
90-102: LGTM! Appropriate error handling for the example.The try/except block properly catches exceptions during parallel LLM execution, logs errors via the context, and handles the case where no result is produced. This is suitable for a demonstration example.
| @@ -0,0 +1,5 @@ | |||
| # Core framework dependency | |||
| mcp-agent @ file://../../../ # Link to the local mcp-agent project root | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify the local dependency path format.
The format mcp-agent @ file://../../../ uses a relative path with the file:// scheme, which is non-standard. According to PEP 508, file:// URLs should typically use absolute paths. Standard alternatives include:
-e ../../../(editable install with relative path)file:///${PWD}(absolute path using environment variable)
Since you mentioned testing was successful, this may work in your environment. However, please verify it works consistently across different installation contexts (local, cloud deployment, CI/CD).
🏁 Script executed:
#!/bin/bash
# Verify the dependency can be installed correctly
cd examples/cloud/observability
python -m pip install --dry-run -r requirements.txt 2>&1 | grep -A5 -B5 "mcp-agent"Length of output: 192
I need to verify if the mcp-agent package has the required packaging files at the repository root.
---
🏁 Script executed:
```shell
#!/bin/bash
# Check for setup.py and pyproject.toml at repository root
fd -d 1 '(setup\.py|pyproject\.toml)$' .
echo "---"
# Also verify directory structure
ls -la | head -20
Length of output: 1229
I need to check the pyproject.toml to understand how the package is declared.
---
🏁 Script executed:
```shell
#!/bin/bash
# Check pyproject.toml for package name and structure
cat pyproject.toml | grep -A 10 "^\[project\]" | head -20
echo "---"
# Also check if there's any name field
grep -E '(name\s*=|version\s*=)' pyproject.toml | head -5
Length of output: 446
Fix the local dependency path format in examples/cloud/observability/requirements.txt.
The file://../../../ format with relative paths fails during installation: pip cannot resolve it and reports that pyproject.toml is not found, even though it exists at the repository root. This confirms the path format is non-standard and unreliable.
Replace with one of these standard alternatives:
-e ../../../(editable install with relative path)- Absolute path using environment variable or full path with
file://scheme
Update line 2 to use a working format:
-e ../../../
🤖 Prompt for AI Agents
In examples/cloud/observability/requirements.txt around line 2, the dependency
uses a non-standard file://../../../ relative URL which pip cannot resolve;
replace that entry with the editable relative-path format -e ../../../ so pip
installs the local mcp-agent project correctly (or alternatively use an absolute
file:// path), and commit the updated requirements.txt.
* wip * Clean up observability example + README * Remove unnecessary filesystem mcp server * Remove spurious comment in requirements * Add activity/task to example

Summary
Add a cloud-deployable example for observability with OTLP endpoints, using Langfuse as the exporter.
Testing
Run locally and deploy to cloud, then run from the server. Both result in traces in Langfuse
Summary by CodeRabbit
New Features
Documentation
Configuration